<template>
  <uv-tabbar :value="current" fixed safeAreaInsetBottom border placeholder zIndex='999' activeColor='#E43222' inactiveColor='#949494' @change="tabClick">
    <uv-tabbar-item :text="item.name" v-for="(item,index) in list" :key="index">
      <template v-slot:active-icon>
        <view class='tabbarIcon'>
          <image class="img" :src="`/static/${item.active}`"></image>
        </view>
      </template>
      <template v-slot:inactive-icon>
        <view class='tabbarIcon'>
          <image class="img" :src="`/static/${item.inactive}`"></image>
        </view>
      </template>
    </uv-tabbar-item>
  </uv-tabbar>
</template>

<script setup>
import { ref } from 'vue';
import { post } from '@/api';

defineProps(['current']);

const list = ref([
  { id: 0, name: '社群', inactive: 'tab1.png', active: 'tab1-select.png' },
  { id: 1, name: '动态', inactive: 'tab2.png', active: 'tab2-select.png' },
  { id: 2, name: '投研有道', inactive: 'tab3.png', active: 'tab3-select.png' },
  { id: 3, name: '约调研', inactive: 'tab4.png', active: 'tab4-select.png' }
])
const url = {
  0: '/pages/index/index',
  1: '/pages/dynamic/index',
  2: '/pages/research/index',
  3: '/pages/invest/index'
}

function tabClick(index){
  // if(index == 3){
  //   post('api/user/getIdentityAuthInfo').then(res => {
  //     if(res.code == 1){
  //       const data = res.data;
  //       if(data){
  //         if(data.examine_status != 1){
  //           uni.navigateTo({
  //             url: '/pages/invest/cert'
  //           });
  //         }else{
  //           uni.navigateTo({
  //             url: url[index]
  //           });
  //         }
  //       }else{
  //         uni.navigateTo({
  //           url: '/pages/invest/cert'
  //         });
  //       }
  //     }
  //   })
  // }else{
    uni.redirectTo({
    	url: url[index]
    });
  // }
}
</script>

<style lang="scss" scoped>
  .tabbarIcon{
    width: 44rpx;
    height: 44rpx;
  }
</style>